<template>
  <div>
    <div class="twoview" v-for="item in catetwo" :key="item.id" ref="two">
      <div class="head">
        <h3>-{{ item.name }}-</h3>
        <p class="tag">温暖柔顺，品质之选</p>
        <div class="ckqb">
          <RouterLink to="/" class="xtx-more">
            <span>查看全部</span>
            <i class="iconfont icon-angle-right"></i>
          </RouterLink>
        </div>
      </div>
      <div class="goods">
        <goods-view :item="item.goods"></goods-view>
      </div>
    </div>
  </div>
</template>

<script>
import { getTwoCate } from "@/utils/api/categoryapi";
import GoodsView from "./GoodsView.vue";
// import { lazyload } from "@/utils/constfun";
export default {
  components: { GoodsView },
  props: ["nowid"],
  data() {
    return {
      catetwo: [],
    };
  },

  watch: {
    nowid() {
      //懒加载
      this.getList();
      // lazyload(this.$refs.two.$el, this.getList);
    },
  },

  methods: {
    async getList() {
      let res = await getTwoCate(this.nowid);
      // console.log(res);
      this.catetwo = res.result.children;
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/assets/css/color.scss";

.twoview {
  width: 100%;
  .head {
    margin-top: 10px;
    width: 100%;
    height: 128px;
    // background: red;
    position: relative;
    h3 {
      font-size: 28px;
      color: #666;
      font-weight: 400;
      text-align: center;
      line-height: 100px;
    }
    .tag {
      text-align: center;
      color: #999;
      font-size: 20px;
      position: relative;
      top: -20px;
    }
    .ckqb {
      position: absolute;
      right: 20px;
      top: 20px;
    }
  }
}
.xtx-more {
  margin-bottom: 2px;
  span {
    font-size: 16px;
    vertical-align: middle;
    margin-right: 4px;
    color: #999;
  }
  i {
    font-size: 14px;
    vertical-align: middle;
    position: relative;
    top: 2px;
    color: #ccc;
  }
  &:hover {
    span,
    i {
      color: $xtxColor;
    }
  }
}
.goods {
  height: 352px;
}
</style>